import { enemyPlane } from "../component/enemyPlane";

const { ccclass, property } = cc._decorator;

@ccclass
export default class enemyPlane_2 extends enemyPlane {
    initData() {
        this.planeIsAttack();
    }

    //设置左右移动
    setNodeMove() {
        let sizeWidth = cc.winSize.width / 2 - this.node.width / 2;
        let act = cc.sequence(cc.moveTo(this.moveTime, cc.v2(-sizeWidth, this.node.y)), cc.moveTo(this.moveTime, cc.v2(sizeWidth, this.node.y)), cc.moveTo(this.moveTime, cc.v2(-sizeWidth, this.node.y)), cc.moveTo(this.moveTime, cc.v2(sizeWidth, this.node.y)));
        this.node.runAction(cc.repeatForever(act));
    }

    setNodePosi(posi) {
        this.node.y = posi;
        this.setNodeMove();
    }

    planeIsAttack() {
        let self = this;
        this.schedule(() => {
            self.attack();
        }, this.attackTime);
    }

    attack() {
        this.getBullet(this.bulletNum, 0, 0, this.nodeBullet);
    }
}
